/*******************************************************************************
 * Copyright (c) 2007 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/

package com.cea.papyrus.extensionpoints.dnd.parsing;

import org.eclipse.gef.EditPart;

import com.cea.papyrus.extensionpoints.dnd.utils.IFilter;

/**
 * Simplified access to DNDFilter
 *
 */
public class GlobalDNDFilter {

	/**
	 * Global test of every filter registered in plugins...
	 * @param draggedObject the dragged object
	 * @param targetEditPart the targeted edit part
	 * @return false on first test fail
	 */
	public static boolean select(Object draggedObject, EditPart targetEditPart) {
		
		// Get and parse DNDFilters
		DNDFilter[] filters = DNDFilter.getDNDFilters();
		for (int i = 0; i < filters.length; i++) {
			
			// Get current filterInstance
			IFilter currentFilter = filters[i].getDNDFilter();
			if (currentFilter != null) {
				if (! currentFilter.select(draggedObject, targetEditPart)) {
					return false;
				}
			}
		}
		
		return true;
	};
}
